<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>我的待诊</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/css/public.css" media="all" />
    <style>
        .top-panel {
            border: 1px solid #eceff9;
            border-radius: 5px;
            text-align: center;
        }
        .top-panel > .layui-card-body{
            height: 60px;
        }
        .top-panel-number{
            line-height:60px;
            font-size: 30px;

        }
        .patLine{
            border-bottom:1px solid #eceff9;

        }

        .opeLine{
            margin-top: 5px;
            margin-bottom: 10px;
        }


        .top-panel-tips{
            line-height:30px;
            font-size: 12px
        }
    </style>
</head>
<body class="childrenBody" style="background-color: #eeeeee">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-md4 layui-col-md-offset4">

                <div class="layui-card top-panel">
                    <div class="layui-card-header">当前待诊患者</div>
                    <div class="layui-card-body">
                        <div class="layui-row layui-col-space5 patLine">
                            <input type="hidden" id="docNo">
                            <input type="hidden" id="id">
                            <div class="layui-col-xs9 layui-col-md8 top-panel-number layui-col-md-offset2" id="patName">

                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-col-space5 opeLine">
                        <div class="layui-col-xs9 layui-col-md8 layui-col-md-offset2">
                            <button class="layui-bg-orange layui-btn layui-btn-sm" id="addRecord">输入病例</button>
                            <button class="layui-bg-cyan layui-btn layui-btn-sm" id="nextPatient">下一位</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
</body>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script>

    layui.use(['jquery','form'],function () {
        var $ = layui.jquery,
            form = layui.form;

         $.ajax({
             url:'/registration/getCurrentPatient',
             type:'GET',
             success:function (res) {
                 console.log(res.data);

                 if (res.code === 200){
                     $('#patName').html(res.data.patName);
                     $('#docNo').val(res.data.doctorNo);
                     $('#id').val(res.data.id);
                 }else{
                     $('#patName').html("工作结束了，您辛苦了");
                 }
             }
         });


         $("#addRecord").click(function () {
             var did = $("#docNo").val();
             var patName = $('#patName').html();

             /*查询患者*/
             $.ajax({
                 url:'/patient/getPatientByName?patName='+patName,
                 type:'GET',
                 success:function (res) {
                     addRecord(did,res.data.id);
                 }
             });
         });


         function addRecord(docNo,patNo){
             var index = layui.layer.open({
                 title : "诊断结果",
                 type : 2,
                 area:['25%','35%'],
                 content : "./addRecord.html",
                 success : function(layero, index){
                     var body = layui.layer.getChildFrame('body', index);
                         body.find("#patNo").val(patNo);
                         body.find("#docNo").val(docNo);
                         form.render();
                     setTimeout(function(){
                         layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                             tips: 3
                         });
                     },1000)
                 }
             })
             layui.layer.full(index);
             //改变窗口大小时，重置弹窗的宽高，防止超出可视区域
             $(window).on("resize",function(){
                 layui.layer.full(index);
             })
         }


        $('#nextPatient').click(function () {
            nextPatient()
        });
         
         
         function nextPatient() {
             $.ajax({
                 url:'/registration/deleteBeforePatient?patId='+$('#id').val(),
                 type:'GET',
                 success:function (res) {
                     window.location.reload();
                 }
             })
         }
    })
</script>
</html>